package test.my.com.myapplicationtest.gesture_lock_view;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

import test.my.com.myapplicationtest.R;

/**
 * Author : Cooper
 * Time : 2017/2/27  16:22
 * Description : 手势密码view
 */

public class GrstureLockViewActivity extends Activity {

    private GestureLockViewGroup gestureLockViewGroup;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aty_grsture_lock_view_layout);

        gestureLockViewGroup = (GestureLockViewGroup) findViewById(R.id.gesture_lock_vg);

        initGestureView();
    }

    private void initGestureView() {
        List<Integer> answer = new ArrayList<>();
        answer.add(1);
        answer.add(2);
        answer.add(3);
        answer.add(4);
        gestureLockViewGroup.setAnswer(answer);
        gestureLockViewGroup.setUnMatchExceedBoundary(3);
        gestureLockViewGroup.setOnGestureLockViewListener(new GestureLockViewGroup.OnGestureLockViewListener() {
            @Override
            public void onBlockSelected(int cId) {
                Log.e("ah","onBlockSelected  ==  "+cId);
            }

            @Override
            public void onGestureEvent(GestureLockViewGroup.DetectionReult matched) {
                switch (matched) {
                    case Frist: // 第一次绘制后，开始进行第二次绘制。常用于设置手势密码。
                        Log.e("ah","onGestureEvent  ==  Frist");
                        break;
                    case NumNot: // 连接的个数不够
                        Log.e("ah","onGestureEvent  ==  NumNot");
                        break;
                    case Pass: // 手势密码正确，通过。
                        Log.e("ah","onGestureEvent  ==  Pass");
                        break;
                    case Reject: // 绘制错误
                        Log.e("ah","onGestureEvent  ==  Reject");
                        break;
                    case ACTION_DOWN:
                        break;
                }
            }

            @Override
            public void onUnmatchedExceedBoundary() {

            }

            @Override
            public void verifyFinish(List<Integer> intArr) {

            }
        });
    }
}
